﻿
Partial Class WebForm_ManageSystemParameter_SearchSystemParameter
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then

            GetParameterTyptItem()
            RaiseEvent Loaded(Me, New EventArgs)

        End If
    End Sub

    Protected Sub btGetData_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btGetData.Click
        Me.BindGV1(ddlParameterType.SelectedValue, "", txtParameterValue.Text.Replace("'", "''"), txtParameterText.Text.Replace("'", "''"), "Y")

        ddlParameterType.SelectedIndex = 0
        ddlActive1.SelectedIndex = 0

    End Sub

    Protected Sub gv_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gv.RowUpdating
        Dim key As DataKey = Me.gv.DataKeys(e.RowIndex)
        Me.SelectedParameterType = key("ParameterType")
        Me.SelectedParameterName = key("ParameterName")

        RaiseEvent Updating(Me, New EventArgs)
    End Sub

    Protected Sub gv_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gv.PageIndexChanging
        Me.gv.PageIndex = e.NewPageIndex
        Me.BindGV1(ddlParameterType.SelectedValue, txtParameterName.Text.Replace("'", "''"), txtParameterValue.Text.Replace("'", "''"), txtParameterText.Text.Replace("'", "''"), ddlActive1.SelectedValue)
    End Sub

End Class

Partial Class WebForm_ManageSystemParameter_SearchSystemParameter
    Public Property SelectedParameterType() As String
        Get
            Return ViewState("ParameterType")
        End Get
        Set(ByVal value As String)
            ViewState("ParameterType") = value
        End Set
    End Property
    Public Property SelectedParameterName() As String
        Get
            Return ViewState("ParameterName")
        End Get
        Set(ByVal value1 As String)
            ViewState("ParameterName") = value1
        End Set
    End Property

    Public Sub BindGV(ByVal ParameterType As String, ByVal ParameterText As String)
        Dim sp As SystemParameterDAO = New SystemParameterDAO()
        gv.DataSource = sp.GetData(ParameterType, "", "", ParameterText, "全部")
        gv.DataBind()
    End Sub

    Public Sub BindGV1(ByVal ParameterType As String, ByVal ParameterName As String, ByVal ParameterValue As String, ByVal ParameterText As String, ByVal Active As String)
        Dim sp As SystemParameterDAO = New SystemParameterDAO()
        gv.DataSource = sp.GetData(ParameterType, ParameterName, ParameterValue, ParameterText, Active)
        gv.DataBind()
    End Sub

    Private Sub GetParameterTyptItem()
        Dim dat As New clsData
        Dim sqlstr As New MyStringBuilder
        Dim dt As New Data.DataTable

        sqlstr.AppendFormat(" select cm.value,cm.Text from CodeMapping cm ")
        sqlstr.AppendFormat(" where cm.TableName = 'SystemParameter' and cm.ColumnName = 'ParameterType' ")

        dt = dat.GetData(sqlstr)

        For i As Integer = 0 To dt.Rows.Count - 1
            Dim item As New ListItem
            item.Value = dt.Rows(i)(0).ToString()
            item.Text = dt.Rows(i)(1).ToString()
            ddlParameterType.Items.Add(item)
        Next



    End Sub

    Public Event Loaded(ByVal source As Object, ByVal e As EventArgs)
    Public Event Adding(ByVal source As Object, ByVal e As EventArgs)
    Public Event Updating(ByVal source As Object, ByVal e As EventArgs)
End Class
